#include <cstring>
#include <iterator>
#include <algorithm>
#include <iostream>
using namespace std;

//n: length of array
//m: positions to be rotated
//TIME = O(n);SPACE = O(1)
//Does not work now!
void rotate_left(int a[],int n, int m)
{
  m = m%n;
  int tmp,i,j;

  for(i=0;i<m;i++){
    tmp = a[i];
    for( j=1;j*m+i<n;j++)
      a[(j-1)*m+i] = a[j*m+i];
    a[n-m+i] = tmp;
  }
}

int main()
{
  int a[] = {0,1,2,3,4,5,6,7,8,9};
  copy(a,a+10,ostream_iterator<int>(cout," "));
  cout<<endl;
  rotate_left(a,10,13);
  copy(a,a+10,ostream_iterator<int>(cout," "));
  cout<<endl;

  return 0;
}
